const express = require("express");
const app = express();
const port = 3000;

// 我们需要再重启一个端口，做即时通讯的端口
const server = app.listen(8082);
const io = require("socket.io").listen(server);

// 建立好之后我们就可以监听前端接入进来的消息了
io.on("connection", (socket) => {
  console.log("a user connected");
  // 如果前端有接入它就会输出这样一句话
});

app.get("/", (req, res) => {
  res.send("Hello World!");
});

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`);
});
